package com.kedacom.ctsp.authz.oauth2;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @Author fenghaiju
 * @date
 */
@Configuration
public class OAuth2ClientDataSourceConfig {
    @Value("${sharding.jdbc.datasource.url}")
    private String url;
    @Value("${sharding.jdbc.datasource.username}")
    private String username;
    @Value("${sharding.jdbc.datasource.password}")
    private String password;
    @Value("${sharding.jdbc.datasource.driver-class-name}")
    private String driver;

    @Bean
    public JdbcTemplate jdbcTemplate() {

        DruidDataSource datasource = new DruidDataSource();

        datasource.setUrl(url);
        datasource.setUsername(username);
        datasource.setPassword(password);
        datasource.setDriverClassName(driver);

        JdbcTemplate customJdbcTemplate = new JdbcTemplate(datasource);
        return customJdbcTemplate;
    }
}
